#pragma once

#include "GridCtrl_src/GridCtrl.h"
#include "TexOrder.h"

struct CellErrorInfo
{
    string    strErrorMsg;
    int       iRowIndex;
    int       iColIndex;
};

class GridCtrlDataBuilder
{
public:
    GridCtrlDataBuilder(CGridCtrl* pGridCtrl);
    virtual ~GridCtrlDataBuilder(void);
    int buildData(TexOrder& order, CellErrorInfo& errInfo);

private:
    #define CELL_VALUE(row, col)    (m_pGridCtrl->GetItemText(row, col))
    #define IS_CELL_NULL(row, col)  ("" == CELL_VALUE(row, col))

private:
    GridCtrlDataBuilder(void);
    GridCtrlDataBuilder(const GridCtrlDataBuilder& other);
    GridCtrlDataBuilder& operator=( const GridCtrlDataBuilder &other);

private:
    int getLastNotNullRow(int& iLastNotNullRow);
    int getCurrItemLastRow(int iCurrItemFirstRow);

private:
    CGridCtrl*       m_pGridCtrl;
};

